﻿using ProductsApp.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace ProductsApp.Controllers
{
    public class EmployeesController : ApiController
    {

        public DataClasses1DataContext dc = new DataClasses1DataContext();
        List<Employee> lst = null;
        Employee[] Employees = new Employee[]{};

        public IEnumerable<Employee> GetAllProducts()
        {
            return Employees;
        }

        public IHttpActionResult GetProduct(int id)
        {
            try
            {
                lst = dc.g_BusinessModelValues.Where(x => x.IsVisible == true && x.ID == id).Select(x => new Employee() { Category = x.BM_Value_Name, Name = x.BM_Value_Name }).Distinct().OrderBy(x => x.Name).ToList();
                var product = lst.First();
                return Ok(product);
            }
            catch (Exception)
            {
               
                throw;
            }
        }
    }
}
